package org.gvp.generator.log;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class Logger {
    private final String className;
    public Logger(Class cls) {
        this.className = cls.getName();
    }


// System.out.println("\033[31m这是红色的文本\033[0m");
    public void debug(String msg) {
        System.out.print(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS")));
        System.out.print("\033[32m [ DEBUG ] \033[0m");
        System.out.print(this.className + " : ");
        System.out.println(msg);
    }

    public void debug(String msg,Object obj) {
        System.out.print(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS")));
        System.out.print("\033[32m [ DEBUG ] \033[0m");
        System.out.print(this.className + " : ");
        System.out.print(msg);
        System.out.println(obj);

    }

    public void warn(String msg) {
        System.out.print(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS")));
        System.out.print("\033[33m [ WARN ] : \033[0m");
        System.out.print(this.className + " : ");
        System.out.println(msg);
    }

    public void error(String msg) {
        System.out.print(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS")));
        System.out.print("\033[31m [ ERROR ] \033[0m");
        System.out.print(this.className + " : ");
        System.out.println(msg);
    }
}
